# -*- coding: utf8 -*-
import os
import sys
import datetime
from google.appengine.ext import db
from google.appengine.api import users
from google.appengine.ext import webapp
from book.models import *
from book import utils
import logging

class ReportHomePage(webapp.RequestHandler):
    def get(self):
        orders = Order.all().order('-date')
        total_price = 0
        order_datas = []
        for order in orders:
            try:
                order.user
                total_price = total_price + order.dish.price
                order_datas.append(order)
            except:
                order.delete()
        context = {
            'current_module' : 'report',
            'orders' : order_datas,
            'total_price' : total_price
        }
        utils.render_to_response(self.response, "report.html", context)
